FROM openjdk:8-jdk-alpine

MAINTAINER delivery-engineering@netflix.com

COPY ./clouddriver-web/build/install/clouddriver /opt/clouddriver

RUN apk --no-cache add --update bash wget unzip 'python2>2.7.9' && \
  wget -nv https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.zip && \
  unzip -qq google-cloud-sdk.zip -d /opt && \
  rm google-cloud-sdk.zip && \
  CLOUDSDK_PYTHON="python2.7" /opt/google-cloud-sdk/install.sh --usage-reporting=false --bash-completion=false --additional-components app-engine-java && \
  rm -rf ~/.config/gcloud

RUN wget https://storage.googleapis.com/kubernetes-release/release/stable.txt && wget https://storage.googleapis.com/kubernetes-release/release/$(cat stable.txt)/bin/linux/amd64/kubectl && \
  rm stable.txt && \
  chmod +x kubectl && \
  mv ./kubectl /usr/local/bin/kubectl

RUN wget https://amazon-eks.s3-us-west-2.amazonaws.com/1.11.5/2018-12-06/bin/linux/amd64/aws-iam-authenticator && \
  chmod +x ./aws-iam-authenticator && \
  mv ./aws-iam-authenticator /usr/local/bin/aws-iam-authenticator && \
  ln -sf /usr/local/bin/aws-iam-authenticator /usr/local/bin/heptio-authenticator-aws

RUN apk -v --update add py-pip && \
  pip install --upgrade awscli==1.14.5 s3cmd==2.0.1 python-magic && \
  apk -v --purge del py-pip && \
  rm /var/cache/apk/*

ENV PATH "$PATH:/usr/local/bin/"

ENV PATH=$PATH:/opt/google-cloud-sdk/bin/

RUN adduser -D -S spinnaker

USER spinnaker

WORKDIR /home/spinnaker
CMD ["/opt/clouddriver/bin/clouddriver"]
